package com.sdy.hospitalguard.web.websocket;

import com.sdy.hospitalguard.web.websocket.base.BaseWebsocketServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import javax.annotation.PostConstruct;
import javax.websocket.server.ServerEndpoint;

@Slf4j
@Component
@ServerEndpoint("/websocket/{connectionId}")
public class WebSocketServer extends BaseWebsocketServer {
    @Autowired
    private ApplicationContext applicationContext;
    private static ApplicationContext applicationContextStatic;
    
    @Override
    protected ApplicationContext getApplicationContext() {
        return applicationContextStatic;
    }
    
    @PostConstruct
    public void init() {
        applicationContextStatic = applicationContext;
    }
}
